package com.piggy.logi.sys.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.piggy.common.core.utils.PageUtils;
import com.piggy.common.core.web.page.PagePlus;
import com.piggy.common.core.web.page.TableDataInfo;
import com.piggy.logi.sys.bo.LogiAccountLogQueryBo;
import com.piggy.logi.sys.domain.LogiAccountLog;
import com.piggy.logi.sys.domain.LogiCarrierDriverLine;
import com.piggy.logi.sys.mapper.LogiAccountLogMapper;
import com.piggy.logi.sys.service.ILogiAccountLogService;
import com.piggy.logi.sys.vo.LogiCarrierDriverLineExtVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 账号日志Service业务层处理
 *
 * @author fengxy
 * @date 2023/10/17 21:54
 **/
@Slf4j
@Service
public class LogiAccountLogServiceImpl extends ServiceImpl<LogiAccountLogMapper, LogiAccountLog> implements ILogiAccountLogService {

    @Override
    public TableDataInfo<LogiAccountLog> queryPageList(LogiAccountLogQueryBo bo) {
        Page<LogiAccountLog> page = page(PageUtils.buildPage(bo), buildQueryWrapper(bo));
        return PageUtils.buildDataInfo(page);
    }

    private Wrapper<LogiAccountLog> buildQueryWrapper(LogiAccountLogQueryBo bo) {
        LambdaQueryWrapper<LogiAccountLog> lqw = Wrappers.lambdaQuery();
        lqw.eq(LogiAccountLog::getUserId, bo.getUserId());
        lqw.orderByDesc(LogiAccountLog::getCreateTime);
        return lqw;
    }
}
